<?php

namespace App\Admin\Controllers;

use Dcat\Admin\Admin;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Layout\Column;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Widgets\Card;
use Illuminate\Support\Facades\Auth;


class HomeController extends AdminController
{
    public function index(Content $content)
    {
        return $content
            ->header('控制台')
            ->body(function (Row $row) {
                $row->column(4, function (Column $column) {
                    $props = [
                        'links'=>[
                            ['title'=>'系统设置','url'=>'/admin/general/config','icon'=>'feather icon-settings','color'=>'bg-primary'],
                            ['title'=>'用户管理','url'=>'/admin/user','icon'=>'feather icon-user','color'=>'bg-success'],
                            ['title'=>'管理员','url'=>'/admin/auth/users','icon'=>'feather icon-users','color'=>'bg-info'],
                            ['title'=>'角色','url'=>'/admin/auth/roles','icon'=>'feather icon-user-plus','color'=>'bg-danger'],
                        ]
                    ];
                    $card = Card::make("快捷操作",vue_render('Dashboard/Link',$props));
                    $column->row($card);
                });
                $row->column(8, function (Column $column) {
                    $admin = Auth::guard('admin');
                    $user = $admin->user();
                    $weeks = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
                    $props = [
                        'user'=>['name'=>$user['name'],'username'=>$user['username']],'date'=>date("Y年m月d日")." ".$weeks[date("w")],
                        'times'=>date("H:i:s"),'weeks'=>$weeks
                    ];
                    $card = Card::make("欢迎管理员",vue_render('Dashboard/Index',$props));
                    $column->row($card);
                });
            });
    }
}
